package ynu.edu.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import ynu.edu.po.Food;
import ynu.edu.service.IFoodService;

import java.util.List;

@RestController
@RequestMapping("/food")
@Tag(name = "食品服务")
public class FoodController {
    @Resource
    private IFoodService foodService;

    @PostMapping("/listFoodByBusinessId")
    @Operation(summary = "查询食品信息",
            description = "根据商家编号查询所属食品信息")
    @Parameter(name = "businessId", description = "商家编号")
    public List<Food> listFoodByBusinessId(@RequestParam Integer businessId) {
        return foodService.listFoodByBusinessId(businessId);
    }

    @PostMapping("/getFoodById")
    @Operation(summary = "查询食品信息",
            description = "根据食品编号查询食品信息")
    @Parameter(name = "foodId", description = "食品编号")
    public Food getFoodById(@RequestParam Integer foodId) {
        return foodService.getFoodById(foodId);
    }

    @GetMapping("/listAllFood")
    @Operation(summary = "查询所有食品信息")
    public List<Food> listAllFood(){
        return foodService.listAllFood();
    }

}
